import { post, get } from './request'

// 用户注册
export const postRegisterXhr = (data: any) => {
  return post(`/users/register`, data)
}

// 用户登录
export const postLoginXhr = (data: any) => {
  return post(`/users/login`, data)
}

// 修改用户信息
export const postUpdateUserInfoXhr = (data: any) => {
  return post(`/users/profile/update`, data)
}

// 发布文章
export const postPublishBlogXhr = (data: any) => {
  return post(`/article/publish`, data)
}
// 获取文章列表
export const getBlogListXhr = (data: any) => {
  return get(`/article/list`, data)
}

// 获取文章详情
export const getBlogDetailXhr = (id: any) => {
  return get(`/article/detail/${id}`)
}

// 删除文章
export const deleteBlogXhr = (data: any) => {
  return post(`/article/delete`, data)
}

// 获取评论列表
export const getCommentListXhr = (data: any) => {
  return get(`/comment/list`, data)
}

// 发布评论
export const postPublishCommentXhr = (data: any) => {
  return post(`/comment/publish`, data)
}

// 回复评论
export const postReplyCommentXhr = (data: any) => {
  return post(`/comment/reply`, data)
}

// 删除评论
export const deleteCommentXhr = (data: any) => {
  return post(`/comment/delete`, data)
}

// ai问答（本地部署 ChatGLM API）
export const postChatGLMMessageXhr = (data: any) => {
  return post(`/ai/chat`, data)
}

// 获取图床列表
export const getPictureListXhr = (data?: any) => {
  return get(`/picture/list`, data)
}

// 删除图片
export const postDeletePictureXhr = (data: any) => {
  return post(`/picture/delete`, data)
}

// 图片上传接口（保存数据库，建议用这个）
export const postUploadPictureXhr = (data: any) => {
  return post(`/picture/upload`, data)
}

// 获取字典
export const getDictListXhr = () => {
  return get(`/dic/list`)
}

// 获取某个字典
export const getDictByKey = (key: string) => {
  return get(`/dic/${key}`)
}

// 修改某个字典值
export const postUpdateDictBykey = (key: string, newValue: any) => {
  return post(`/dic/update/${key}`, { value: newValue })
}

// 新增字典接口
export const postAddDict = (key: string, value: any, description: string) => {
  return post(`/dic/add`, { key, value, description })
}
